﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using DualControl.Controllers;
using DualControl.ControlMeasures;
using DualControl.ControlMeasures.Dtos;
using DualControl.ControlMeasures.Dtos.CustomMapper;
using DualControl.HazardSources;
using DualControl.HazardSources.Dtos;
using DualControl.RiskPoints.Dtos;
using Microsoft.AspNetCore.Mvc;
using X.PagedList;

namespace DualControl.Web.Mvc.Controllers
{
    public class ControlMeasureController : DualControlControllerBase
    {
       
        private readonly IControlMeasureAppService _controlMeasureAppService;

        public ControlMeasureController(IControlMeasureAppService controlMeasureAppService
            )
        {
            _controlMeasureAppService = controlMeasureAppService;
        }

        public async Task<IActionResult> Index(int page, string view)
        {
            int pagenumber = page < 1 ? 1 : page;
            GetControlMeasuresInput input = new GetControlMeasuresInput
            {
                SkipCount = (pagenumber - 1) * AppConsts.DefaultPageSize,
                MaxResultCount = AppConsts.DefaultPageSize
            };
            //var result = await _hazardSourceAppService.GetPagedHazardSources(input);
            var result = await _controlMeasureAppService.GetPagedHSControlMeasure(input);



            var PageOfHSControlMeasureListDto = new StaticPagedList<HSControlMeasureListDto>(result.Items, pagenumber, AppConsts.DefaultPageSize, result.TotalCount);
            //将分页结果放入ViewBag供View使用
            ViewBag.PageOfHSControlMeasureListDto = PageOfHSControlMeasureListDto;
            return View(view);
        }

    

        /// <summary>
        /// 排查标准
        /// </summary>
        /// <param name="page"></param>
        /// <returns></returns>
       public async Task<IActionResult> HTCriteria(int page)
        {
            int pagenumber = page < 1 ? 1 : page;
            GetControlMeasuresInput input = new GetControlMeasuresInput
            {
                SkipCount = (pagenumber - 1) * AppConsts.DefaultPageSize,
                MaxResultCount = AppConsts.DefaultPageSize
            };
            
            var result = await _controlMeasureAppService.GetPagedHTCriteriaListDto(input);

            var PageOfHTCriteriaListDto = new StaticPagedList<HTCriteriaListDto>(result.Items, pagenumber, AppConsts.DefaultPageSize, result.TotalCount);
            //将分页结果放入ViewBag供View使用
            ViewBag.PageOfHTCriteriaListDto = PageOfHTCriteriaListDto;
            return View();
        }






    }
}